import numpy as np
from scipy import linalg
from matplotlib import pyplot as plt

matrix=np.matrix([[1,2],[3,4]])
inverse_matrix=linalg.inv(matrix)
print(inverse_matrix)

U,s,Vh=linalg.svd(np.random.randn(5,4))
print(U,Vh,s)

x=np.array([1,2.5,3.5,4,5,7,8.5])
y=np.array([0.3,1.1,1.5,2.0,3.2,6.6,8.6])
M=x[:,np.newaxis]**[0,2]
p=linalg.lstsq(M,y)[0]
print(M,p)
plt.scatter(x,y)
plt.show()
xx=np.linspace(0,10,100)
yy=p[0]+p[1]*xx**2
plt.plot(xx,yy)
plt.show()
